package com.wyh.controller.groupOne.contractManagement;


import com.wyh.common.result.Result;
import com.wyh.domain.vo.groupOne.contractManagement.ContractAddVO;
import com.wyh.domain.vo.groupOne.contractManagement.ContractChangeVO;
import com.wyh.domain.vo.groupOne.contractManagement.ContractDetailsVO;
import com.wyh.domain.vo.groupOne.contractManagement.MasterDataContractVO;
import com.wyh.domain.vo.groupOne.customer.MasterDataCustomerVO;
import com.wyh.service.groupOne.contractManagement.MasterDataIContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 合同表 前端控制器
 * </p>
 *
 * @author lsf
 * @since 2024-06-03
 */
@RestController
@RequestMapping("/contract")
public class MasterDataContractController {

    @Autowired
    private MasterDataIContractService contractService;


    /**
     * 条件分页查询合同
     * @param masterDataContractVO
     * @return
     */
    @RequestMapping("/contractList")
    public Result<List<MasterDataContractVO>> contractList(@RequestBody MasterDataContractVO masterDataContractVO){


        return contractService.contractList(masterDataContractVO);
    }

    /**
     * 详情页
     * @param contractId
     *
     */
    @GetMapping("/getContractDetails")
    public Result<ContractDetailsVO> getContractDetails(@RequestParam Integer contractId){

        return contractService.getContractDetails(contractId);
    }

    /**
     * 详情页编辑
     * @param contractChangeVO
     *
     */

    @PostMapping("/changeContract")
    public Result changeContract(@RequestBody ContractChangeVO contractChangeVO){
        return contractService.changeContract(contractChangeVO);
    }


    /**
     * 作废合同
     * @param id
     * @return
     */
    @GetMapping("/cancleContract")
    public Result cancleContract(@RequestParam Integer id){
        return contractService.cancleContract(id);
    }

    /**
     * 新增合同
     * @param contractAddVO
     * @return
     */
    @PostMapping("/addContract")
    public Result addContract(@RequestBody ContractAddVO contractAddVO){
        return contractService.addContract(contractAddVO);
    }

    /**
     * 获取新增合同时客户列表
     * @param input
     * @return
     */
    @GetMapping("/getCustomer")
    public Result<List<MasterDataCustomerVO>> getCustomer(@RequestParam String input){
        return contractService.getCustomer(input);
    }


 }
